package com.fs.domain.helper;

import com.fs.domain.MonitorFalcon;
import com.fs.util.DateUtil;
import com.fs.vo.MonitorFalconVo;
import org.apache.commons.collections4.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by fengshuai on 17/5/18.
 */
public class MonitorFalconHelper {

    public static List<MonitorFalconVo> convertToVos(List<MonitorFalcon> source) {
        List<MonitorFalconVo> dst = new ArrayList<>();
        if (CollectionUtils.isEmpty(source)) {
            return dst;
        }
        for (MonitorFalcon e : source) {
            MonitorFalconVo d = convertToVo(e);
            if (d != null) {
                dst.add(d);
            }
        }
        return dst;
    }

    public static MonitorFalconVo convertToVo(MonitorFalcon source) {
        if (source == null) {
            return null;
        }
        MonitorFalconVo vo = new MonitorFalconVo();
        vo.setId(source.getId());
        vo.setDay(source.getDay());
        vo.setDbId(source.getDb_id());
        vo.setSegment(source.getSegment());
        vo.setQps(source.getQps());
        vo.setTs(DateUtil.seconds2TimeFormat(source.getTs(), "yyyy-MM-dd HH:mm:ss"));
        vo.setMachine(source.getMachine());
        vo.setCtime(source.getCtime());
        vo.setUtime(source.getUtime());
        vo.setValid(source.getValid());
        return vo;
    }
}
